package com.qujia.station.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qujia.common.annotation.Log;
import com.qujia.common.core.controller.BaseController;
import com.qujia.common.core.domain.AjaxResult;
import com.qujia.common.enums.BusinessType;
import com.qujia.station.domain.StationNotice;
import com.qujia.station.service.IStationNoticeService;
import com.qujia.common.utils.poi.ExcelUtil;
import com.qujia.common.core.page.TableDataInfo;

/**
 * 油站通知管理Controller
 * 
 * @author qujia
 * @date 2020-12-08
 */
@RestController
@RequestMapping("/station/notice")
public class StationNoticeController extends BaseController
{
    @Autowired
    private IStationNoticeService stationNoticeService;

    /**
     * 查询油站通知管理列表
     */
    @PreAuthorize("@ss.hasPermi('station:notice:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationNotice stationNotice)
    {
        startPage();
        List<StationNotice> list = stationNoticeService.selectStationNoticeList(stationNotice);
        return getDataTable(list);
    }

    /**
     * 导出油站通知管理列表
     */
    @PreAuthorize("@ss.hasPermi('station:notice:export')")
    @Log(title = "油站通知管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StationNotice stationNotice)
    {
        List<StationNotice> list = stationNoticeService.selectStationNoticeList(stationNotice);
        ExcelUtil<StationNotice> util = new ExcelUtil<StationNotice>(StationNotice.class);
        return util.exportExcel(list, "notice");
    }

    /**
     * 获取油站通知管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('station:notice:query')")
    @GetMapping(value = "/{noticeId}")
    public AjaxResult getInfo(@PathVariable("noticeId") Long noticeId)
    {
        return AjaxResult.success(stationNoticeService.selectStationNoticeById(noticeId));
    }

    /**
     * 新增油站通知管理
     */
    @PreAuthorize("@ss.hasPermi('station:notice:add')")
    @Log(title = "油站通知管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationNotice stationNotice)
    {
        return toAjax(stationNoticeService.insertStationNotice(stationNotice));
    }

    /**
     * 修改油站通知管理
     */
    @PreAuthorize("@ss.hasPermi('station:notice:edit')")
    @Log(title = "油站通知管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationNotice stationNotice)
    {
        return toAjax(stationNoticeService.updateStationNotice(stationNotice));
    }

    /**
     * 删除油站通知管理
     */
    @PreAuthorize("@ss.hasPermi('station:notice:remove')")
    @Log(title = "油站通知管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noticeIds}")
    public AjaxResult remove(@PathVariable Long[] noticeIds)
    {
        return toAjax(stationNoticeService.deleteStationNoticeByIds(noticeIds));
    }
}
